package practice1_100;

public class Practice101 {
    public boolean isSymmetric(TreeNode root) {
        if(root==null)return true;
        if(root.left==null&&root.right==null) return true;
        return dp(root.left,root.right);
    }
    public boolean dp(TreeNode left,TreeNode right){
        if(left==null&&right==null) return true;
        if(left!=null&&right==null) return false;
        if(left==null&&right!=null) return false;
        //if(left!=null&&right!=null) return left.val== right.val;

        return left.val== right.val&&dp(left.left,right.right)&&dp(left.right,right.left);
    }

    public static void main(String[] args) {
        boolean a=new Practice101().isSymmetric(new TreeNode(1,new TreeNode(2,new TreeNode(3),new TreeNode(4)),new TreeNode(2,new TreeNode(4),new TreeNode(2))));
        System.out.println(a);
    }
}
